package com.lehecai.core.api.openapi;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import com.lehecai.core.api.AbstractApiResultBean;

/**
 * 二维码
 * @author He Wang
 *
 */
public class QrCodeScan extends AbstractApiResultBean {
	
	
	
	public static final String IPHONE_SCAN_NUM = "ios";
	public static final String IPAD_SCAN_NUM = "ipad";
	public static final String ANDROID_SCAN_NUM = "android";
	public static final String ELSE_SCAN_NUM = "else";
	public static final String TOTAL_SCAN_NUM = "total";

	
	public static final String QUERY_QR_CODE_ID = "qr_id";
	public static final String QUERY_SCAN_DATE = "scan_date";
	
	public static final String QUERY_SCAN_DATE_START = "start";
	public static final String QUERY_SCAN_DATE_END = "end";
	
	public static final String QR_LOG_ID = "log_id";
	
	private long qrCodeId;
	private Integer iphoneScanNum;
	private Integer ipadScanNum;
	private Integer androidScanNum;
	private Integer elseScanNum;
	private Integer totalScanNum;
	
	private String scanDateStr;
	
	public static QrCodeScan convertFromJSONObject(JSONObject object) {
		if (object == null) {
			return null;
		}
		QrCodeScan qrCodeScan = new QrCodeScan();
		qrCodeScan.setIphoneScanNum(getInt(object, IPHONE_SCAN_NUM));
		qrCodeScan.setIpadScanNum(getInt(object, IPAD_SCAN_NUM));
		qrCodeScan.setAndroidScanNum(getInt(object, ANDROID_SCAN_NUM));
		qrCodeScan.setElseScanNum(getInt(object, ELSE_SCAN_NUM));
		qrCodeScan.setTotalScanNum(getInt(object, TOTAL_SCAN_NUM));
		qrCodeScan.setScanDateStr(getString(object, QUERY_SCAN_DATE));
		return qrCodeScan;
	}
	
	public static List<QrCodeScan> convertFromJSONArray(JSONArray array) {
		if (array == null) {
			return null;
		}
		List<QrCodeScan> list = new ArrayList<QrCodeScan>();
		for (Iterator<?> iterator = array.iterator(); iterator.hasNext();) {
			JSONObject object = (JSONObject) iterator.next();
			list.add(convertFromJSONObject(object));
		}
		return list;
	}

	public long getQrCodeId() {
		return qrCodeId;
	}

	public void setQrCodeId(long qrCodeId) {
		this.qrCodeId = qrCodeId;
	}

	public void setIpadScanNum(Integer ipadScanNum) {
		this.ipadScanNum = ipadScanNum;
	}

	public Integer getIpadScanNum() {
		return ipadScanNum;
	}

	public void setAndroidScanNum(Integer androidScanNum) {
		this.androidScanNum = androidScanNum;
	}

	public Integer getAndroidScanNum() {
		return androidScanNum;
	}

	public void setElseScanNum(Integer elseScanNum) {
		this.elseScanNum = elseScanNum;
	}

	public Integer getElseScanNum() {
		return elseScanNum;
	}

	public void setTotalScanNum(Integer totalScanNum) {
		this.totalScanNum = totalScanNum;
	}

	public Integer getTotalScanNum() {
		return totalScanNum;
	}

	public void setIphoneScanNum(Integer iphoneScanNum) {
		this.iphoneScanNum = iphoneScanNum;
	}

	public Integer getIphoneScanNum() {
		return iphoneScanNum;
	}

	public void setScanDateStr(String scanDateStr) {
		this.scanDateStr = scanDateStr;
	}

	public String getScanDateStr() {
		return scanDateStr;
	}

}
